package com.penghaisoft.microwms.product.web.controller.outwarehouse;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.penghaisoft.microwms.common.controller.BaseController;
import com.penghaisoft.microwms.common.data.model.ProHandOutSn;
import com.penghaisoft.microwms.common.dto.TransResult;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.IWmsCommonService;
import com.penghaisoft.microwms.product.service.IProHandOutService;
import com.penghaisoft.microwms.product.service.IProHandOutSnService;

import lombok.extern.slf4j.Slf4j;

/**
 * PC手工出库明细
 * @author liwenjiang
 *
 */
@RestController
@RequestMapping(value = "/handSn")
@Slf4j
public class ProHandOutSnController extends BaseController {
    @Autowired
    private IProHandOutSnService proHandOutSnService;
    
    @PostMapping("list")
    public TransResult list (@RequestParam(name = "page", defaultValue = "1") int page,
            @RequestParam(name = "rows", defaultValue = "10") int rows,ProHandOutSn proHandOutSn){
				
    	Pager<ProHandOutSn> result =proHandOutSnService.findListByCondition(page, rows, proHandOutSn);
    	
    	return success(result);
    }
    
    @PostMapping("outOrder")
	public TransResult queryOrder(@RequestParam(name = "page", defaultValue = "1") int page,
            @RequestParam(name = "rows", defaultValue = "10") int rows, ProHandOutSn proHandOutSn){
		
		Pager<ProHandOutSn> result = proHandOutSnService.queryOrder(page,rows,proHandOutSn);
		
		String sumInfo = result.getOrder();
		if (sumInfo != null && sumInfo.length() > 0) {
			result.setOrder(sumInfo);
		}
		return success(result);
	}
    
}
